package com.skyline.user.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.user.model.EmailToken;
import com.skyline.user.type.EmailTokenType;

public class EmailTokenMapper implements RowMapper<EmailToken> {

	private final static EmailTokenMapper MAPPER = new EmailTokenMapper();

	public static EmailTokenMapper getMapper() {
		return MAPPER;
	}

	@Override
	public EmailToken mapRow(ResultSet rs, int arg1) throws SQLException {
		EmailToken t = new EmailToken();
		t.setChecked(rs.getBoolean("checked"));
		try {
			t.setCheckTime(rs.getTimestamp("checkTime"));
		} catch (Exception e) {
		}
		t.setEmail(rs.getString("email"));
		t.setId(rs.getLong("id"));
		t.setToken(rs.getString("token"));
		t.setType(EmailTokenType.valueOf(rs.getString("type")));
		t.setUserId(rs.getLong("userId"));
		return t;
	}

}
